

import QtQuick 2.6
import QtQuick.Layouts 1.0
import QtQuick.Controls 2.1


Page {
    id: page


    property var qmldevice :JSON.parse(qmlconncpp.getqmlDevice(0))
    property var qmldeviceProtocolGroup :JSON.parse(qmlconncpp.getqmlDeviceProtocolGroup())
    property var qmldeviceProtocolName :JSON.parse(qmlconncpp.getqmlDeviceProtocolByGroup(qmldeviceProtocolGroup[0]))
    property var qmlserverSendTask :JSON.parse(qmlconncpp.getqmlServerSendTask());


    SwipeView {
        id: swipeView
        anchors.fill: parent
        currentIndex: tabBar.currentIndex

        //第一页
        Pane {
            width: swipeView.width
            height: swipeView.height

            Rectangle {
                width: parent.width
                id:row01;
                height:5;
                //color:"blue";
                anchors.top: parent.top;

            }
                //radius: 8

            //设备列表
            Rectangle {
                    id:row02;
                    width: parent.width
                    height:450;
                    //color:"blue";
                    anchors.top: row01.bottom;
                    border
                    {
                        color: "blue"
                        width: 1
                    }
                    ListView {
                         id:lv2

                         anchors.verticalCenter: parent.verticalCenter
                         width: parent.width-8;
                         height: parent.height*0.8;

                         model: devicelist//.polygons

                         delegate: ItemDelegate {

                                 Rectangle {
                                     width: 10
                                     height: parent.height/2
                                     color: colorCode
                                     anchors.verticalCenter: parent.verticalCenter
                                 }
                                 Text{
                                     font.pixelSize: 12
                                     font.family: "Microsoft YaHei"//qsTr("")
                                     text: "   "+name+"(端口:"+portName+",协议:"+protocolLib+"-"+protocol+"),地址:"+commAddr+"):|:"+dataString
                                     anchors.verticalCenter: parent.verticalCenter
                                 }
                                 width: parent.width
                                 onClicked: {
                                     console.log("clicked deviceId:", deviceId);
                                     //qmlconncpp.clickDeviceItem(index);
                                     qmlconncpp.getqmlDevice(deviceId);
                                     qmldevice=JSON.parse(qmlconncpp.qmlDevice);
                                     //qmldeviceProtocolName=JSON.parse(qmlconncpp.getqmlDeviceProtocolByGroup(selectProtocolGroup.currentText));
                                    for(var i=0;i<selectProtocolName.count;i++)
                                    {
                                        if(selectProtocolName.model[i].protocolId===qmldevice[0].protocolId){selectProtocolName.currentIndex=i;break;}
                                    }
                                     deviceDialog.open();
                                 }
                         }

                         ScrollIndicator.vertical: ScrollIndicator { }
                    }

            }
            //设备添加按钮
            Rectangle {
                width: 35
                height:35;
                color:"blue";
                anchors.bottom: row02.bottom;
                anchors.right: row02.right;

                Button {
                    id: dlistadd_btn
                    width: parent.width*0.95
                    height: parent.height*0.95
                    anchors.centerIn: parent
                    text: "+"
                    font.family: "Microsoft YaHei"
                    font.pixelSize: 25
                    onClicked: {
                        qmldevice=JSON.parse("[{\"deviceId\":\"0\",\"deviceAddr\":\"1\"}]")
                        deviceDialog.open();
                    }
                 }

            }




            Rectangle {
                width: parent.width
                id:row03;
                height:20;
                //color:"blue";
                anchors.top: row02.bottom;

             }

            //上报平台列表
            Rectangle {
                id:row04;
                width: parent.width
                height:150;
                //color:"blue";
                anchors.top: row03.bottom;
                border
                {
                    color: "blue"
                    width: 1
                }

                 ListView {
                     id: lv3
                     anchors.verticalCenter: parent.verticalCenter
                     width: parent.width-8;
                     height: parent.height*0.6;
                     model: hostlist
                     ScrollIndicator.vertical: ScrollIndicator {
                     }
                     delegate: ItemDelegate {
                         width: parent.width
                         Rectangle {
                             width: 10
                             height: parent.height/2
                             color: colorCode
                             anchors.verticalCenter: parent.verticalCenter
                         }

                         Text {
                             text: "   "+name+"(IP"+hostIp+",端口"+hostPort+",协议"+protocol+"):|:"+dataString
                             anchors.verticalCenter: parent.verticalCenter
                             font.pixelSize: 12
                             font.family: "Microsoft YaHei"
                         }
                         onClicked: {
                             console.log("clicked:", index);
                             //qmlconncpp.clickHostItem(index);
                             hostDialog.open();
                         }
                     }
                 }

              }
             //上报平台添加按钮
            Rectangle {
                width: 35
                height:35;
                color:"blue";
                anchors.bottom: row04.bottom;
                anchors.right: row04.right;

                Button {
                    id: nlistadd_btn
                    width: parent.width*0.95
                    height: parent.height*0.95
                    anchors.centerIn: parent
                    text: "+"
                    font.family: "Microsoft YaHei"
                    font.pixelSize: 25
                    onClicked: {
                        hostDialog.open();
                    }
                 }

            }


        }
        //第二页
        Pane {
            width: swipeView.width
            height: swipeView.height

            Rectangle {
                width: parent.width
                id:row01b;
                height:5;
                //color:"blue";
                anchors.top: parent.top;

            }
                //radius: 8
            //因子列表
            Rectangle {
                    id:row02b;
                    width: parent.width
                    height:250;
                    //color:"blue";
                    anchors.top: row01b.bottom;
                    border
                    {
                        color: "blue"
                        width: 1
                    }

                    ListView {
                         id:lv1b

                         anchors.verticalCenter: parent.verticalCenter
                         width: parent.width-8;
                         height: parent.height*0.8;

                         model: codelist

                         delegate: ItemDelegate {

                                 Rectangle {
                                     width: 10
                                     height: parent.height/2
                                     color: "black";
                                     anchors.verticalCenter: parent.verticalCenter
                                 }
                                 Text{
                                     font.pixelSize: 12
                                     font.family: "Microsoft YaHei"//qsTr("")
                                     text: "   ID:"+id+",("+codeName+"):"+dataString;
                                     anchors.verticalCenter: parent.verticalCenter
                                 }
                                 width: parent.width
                                 onClicked: {
                                    //console.log(JSON.stringify(qmlserverSendTask));
                                 }
                         }

                         ScrollIndicator.vertical: ScrollIndicator { }
                    }

            }
            Rectangle {
                width: parent.width
                id:row03b;
                height:20;
                //color:"blue";
                anchors.top: row02b.bottom;

             }
            //上报任务列表
            Rectangle {
                    id:row04b;
                    width: parent.width
                    height:350;
                    //color:"blue";
                    anchors.top: row03b.bottom;
                    border
                    {
                        color: "blue"
                        width: 1
                    }

                    ListView {
                         id:lv2b

                         anchors.verticalCenter: parent.verticalCenter
                         width: parent.width-8;
                         height: parent.height*0.8;

                         model: qmlserverSendTask

                         delegate: ItemDelegate {

                                 Rectangle {
                                     width: 10
                                     height: parent.height/2
                                     color: (qmlserverSendTask[index].sendNotOk===0)?"green":"red";
                                     anchors.verticalCenter: parent.verticalCenter
                                 }
                                 Text{
                                     font.pixelSize: 12
                                     font.family: "Microsoft YaHei"//qsTr("")
                                     text: "   平台ID:"+qmlserverSendTask[index].serverId+",(ST"+qmlserverSendTask[index].st+",CN"+qmlserverSendTask[index].cn+"),数据时间:"+qmlserverSendTask[index].msgQN+",最后上报:"+qmlserverSendTask[index].sendQN+"):|:上报状态:"+((qmlserverSendTask[index].sendNotOk===0)?("上报成功"):("上报第"+qmlserverSendTask[index].sendNotOk+"次"));
                                     anchors.verticalCenter: parent.verticalCenter
                                 }
                                 width: parent.width
                                 onClicked: {
                                    //console.log(JSON.stringify(qmlserverSendTask));
                                 }
                         }

                         ScrollIndicator.vertical: ScrollIndicator { }
                    }

            }

            //任务刷新按钮
            Rectangle {
                width: 70
                height:35;
                color:"blue";
                anchors.bottom: row04b.bottom;
                anchors.right: row04b.right;

                Button {
                    id: tlistrfs_btn
                    width: parent.width*0.95
                    height: parent.height*0.95
                    anchors.centerIn: parent
                    text: "刷新"
                    font.family: "Microsoft YaHei"
                    font.pixelSize: 25
                    onClicked: {
                        qmlserverSendTask=JSON.parse(qmlconncpp.getqmlServerSendTask());
                    }
                 }

            }

        }
        //第三页
        Pane {
            width: swipeView.width
            height: swipeView.height


            Rectangle {
                width: parent.width
                id:row01c;
                height:50;
                anchors.top: parent.top;

                Rectangle {
                    width: parent.width*0.05;
                    id:row01c_c01;
                    height:parent.height;
                    anchors.left: parent.left;

                    Text {
                        color: "#0c00d5"
                        text: qsTr("编号: ")
                        anchors.right: parent.right
                        anchors.verticalCenter: parent.verticalCenter
                        font.family: "Microsoft YaHei"
                        font.pixelSize: 15;
                    }

                }

                Rectangle {
                    width: parent.width*0.40;
                    id:row01c_c02;
                    height:parent.height;
                    anchors.left: row01c_c01.right;
                    Text {
                        //color: "#0c00d5"
                        text: station.MN
                        anchors.left: parent.left
                        anchors.verticalCenter: parent.verticalCenter
                        font.family: "Microsoft YaHei"
                        font.pixelSize: 15;
                    }
//                    TextField {
//                        id: inputIp1
//                        text: station.MN//"010000A8900016F000169DC0"
//                        enabled: false
//                        font.pixelSize: 10
//                        renderType: Text.QtRendering
//                        scale: 1
//                        font.family: "Microsoft YaHei"
//                        wrapMode: Text.NoWrap
//                        placeholderText: "MN"
//                        inputMethodHints: Qt.ImhDigitsOnly
//                        z: 0
//                        opacity: 1
//                    }
                }
                Rectangle {
                    width: parent.width*0.05;
                    id:row01c_c03;
                    height:parent.height;
                    anchors.left: row01c_c02.right;
                    Text {
                        color: "#0c00d5"
                        text: qsTr("密码: ")
                        anchors.right: parent.right
                        anchors.verticalCenter: parent.verticalCenter
                        font.pixelSize: 15
                        font.family: "Microsoft YaHei"
                        styleColor: "#00000000"
                    }
                }
                Rectangle {
                    width: parent.width*0.2;
                    id:row01c_c04;
                    height:parent.height;
                    anchors.left: row01c_c03.right;
                    Text {
                        text: station.PW
                        anchors.verticalCenter: parent.verticalCenter
                        font.pixelSize: 15
                        font.family: "Microsoft YaHei"
                        styleColor: "#00000000"
                    }
                }
                Rectangle {
                    width: parent.width*0.05;
                    id:row01c_c05;
                    height:parent.height;
                    anchors.left: row01c_c04.right;
                    Text {
                        color: "#0c00d5"
                        text: qsTr("时间: ")
                        anchors.right: parent.right
                        anchors.verticalCenter: parent.verticalCenter
                        font.pixelSize: 15
                        font.family: "Microsoft YaHei"
                        styleColor: "#00000000"
                    }
                }
                Rectangle {
                    width: parent.width*0.1;
                    id:row01c_c06;
                    height:parent.height;
                    anchors.left: row01c_c05.right;
                    Text {
                        text: station.SystemTime
                        anchors.verticalCenter: parent.verticalCenter
                        font.pixelSize: 15
                        font.family: "Microsoft YaHei"
                        styleColor: "#00000000"
                    }
                }

            }

            Rectangle {
                width: parent.width
                id:row02c;
                height:50;
                anchors.top: row01c.bottom;

                Rectangle {
                    width: parent.width*0.05;
                    id:row02c_c01;
                    height:parent.height;
                    anchors.left: parent.left;

                    Text {
                        color: "#0c00d5"
                        text: qsTr("超时: ")
                        anchors.left: parent.left
                        anchors.verticalCenter: parent.verticalCenter
                        font.family: "Microsoft YaHei"
                        font.pixelSize: 15;
                    }

                }

                Rectangle {
                    width: parent.width*0.1;
                    id:row02c_c02;
                    height:parent.height;
                    anchors.left: row02c_c01.right;
                    Text {
                        text: station.OverTime+" 秒";
                        anchors.verticalCenter: parent.verticalCenter;
                        font.pixelSize: 15;
                        font.family: "Microsoft YaHei";
                        styleColor: "#00000000";
                    }
                }

                Rectangle {
                    width: parent.width*0.05;
                    id:row02c_c03;
                    height:parent.height;
                    anchors.left: row02c_c02.right;

                    Text {
                        color: "#0c00d5"
                        text: qsTr("重发: ")
                        anchors.right: parent.right
                        anchors.verticalCenter: parent.verticalCenter
                        font.family: "Microsoft YaHei"
                        font.pixelSize: 15;
                    }

                }

                Rectangle {
                    width: parent.width*0.1;
                    id:row02c_c04;
                    height:parent.height;
                    anchors.left: row02c_c03.right;
                    Text {
                        text: station.ReCount +" 次";
                        anchors.verticalCenter: parent.verticalCenter
                        font.pixelSize: 15
                        font.family: "Microsoft YaHei"
                        styleColor: "#00000000"
                    }
                }

            }


            Rectangle {
                width: parent.width
                id:row03c;
                height:50;
                anchors.top: row02c.bottom;

                Rectangle {
                    width: parent.width*0.2;
                    id:row03c_c01;
                    height:parent.height;
                    anchors.left: parent.left;

                    Text {
                        color: "#0c00d5"
                        text: qsTr("实时数据上报间隔: ")
                        anchors.left: parent.left
                        anchors.verticalCenter: parent.verticalCenter
                        font.family: "Microsoft YaHei"
                        font.pixelSize: 15;
                    }

                }

                Rectangle {
                    width: parent.width*0.1;
                    id:row03c_c02;
                    height:parent.height;
                    anchors.left: row03c_c01.right;
                    Text {
                        text: station.RtdInterval+" 秒";
                        anchors.verticalCenter: parent.verticalCenter
                        font.pixelSize: 15
                        font.family: "Microsoft YaHei"
                        styleColor: "#00000000"
                    }
                }

            }


            Rectangle {
                width: parent.width
                id:row04c;
                height:50;
                anchors.top: row03c.bottom;

                Rectangle {
                    width: parent.width*0.2;
                    id:row04c_c01;
                    height:parent.height;
                    anchors.left: parent.left;

                    Text {
                        color: "#0c00d5"
                        text: qsTr("分钟数据上报间隔: ")
                        anchors.left: parent.left
                        anchors.verticalCenter: parent.verticalCenter
                        font.family: "Microsoft YaHei"
                        font.pixelSize: 15;
                    }

                }

                Rectangle {
                    width: parent.width*0.1;
                    id:row04c_c02;
                    height:parent.height;
                    anchors.left: row04c_c01.right;
                    Text {
                        text: station.MinInterval+" 分钟";
                        anchors.verticalCenter: parent.verticalCenter
                        font.pixelSize: 15
                        font.family: "Microsoft YaHei"
                        styleColor: "#00000000"
                    }
                }

            }

            Rectangle {
                width: parent.width
                id:row05c;
                height:50;
                anchors.top: row04c.bottom;

                Rectangle {
                    width: parent.width*0.25;
                    id:row05c_c01;
                    height:parent.height;
                    anchors.left: parent.left;

                    Text {
                        color: "#0c00d5"
                        text: qsTr("污染物数据实时上报: ")
                        anchors.left: parent.left
                        anchors.verticalCenter: parent.verticalCenter
                        font.family: "Microsoft YaHei"
                        font.pixelSize: 15;
                    }

                }

                Rectangle {
                    width: parent.width*0.1;
                    id:row05c_c02;
                    height:parent.height;
                    anchors.left: row05c_c01.right;
                    Text {
                        text: station.RealtimeReport ? "开启" : "关闭";
                        anchors.verticalCenter: parent.verticalCenter
                        font.pixelSize: 15
                        font.family: "Microsoft YaHei"
                        styleColor: "#00000000"
                    }
                }

            }

            Rectangle {
                width: parent.width
                id:row06c;
                height:50;
                anchors.top: row05c.bottom;

                Rectangle {
                    width: parent.width*0.25;
                    id:row06c_c01;
                    height:parent.height;
                    anchors.left: parent.left;

                    Text {
                        color: "#0c00d5"
                        text: qsTr("治理设施状态实时上报: ")
                        anchors.left: parent.left
                        anchors.verticalCenter: parent.verticalCenter
                        font.family: "Microsoft YaHei"
                        font.pixelSize: 15;
                    }

                }

                Rectangle {
                    width: parent.width*0.1;
                    id:row06c_c02;
                    height:parent.height;
                    anchors.left: row06c_c01.right;
                    Text {
                        text: station.DeviceStateView ? "开启" : "关闭";
                        anchors.verticalCenter: parent.verticalCenter
                        font.pixelSize: 15
                        font.family: "Microsoft YaHei"
                        styleColor: "#00000000"
                    }
                }

            }


            //分割线
            Rectangle {
                width: parent.width
                id:row07c;
                height:20;
                //color:"blue";
                anchors.top: row06c.bottom;

                Rectangle {
                    width: parent.width
                    id:row07c_c01;
                    height:5;
                    color:"blue";
                    anchors.centerIn: parent;

                    }
                }



            //按钮区1
           Rectangle {
                   width: parent.width
                   id:row08c;
                   height:80;
                   //color:"blue";
                   anchors.top: row07c.bottom;

                   Rectangle {
                       id:row08c_c01;
                       width: parent.width*0.2;
                       height:parent.height*0.8
                       anchors.left: parent.left;
                       Button {
                           id: button2011
                           width: parent.width*0.8
                           height: parent.height*0.7
                           anchors.centerIn: parent
                           text: "上传实时数据"
                           font.family: "Microsoft YaHei"
                           font.pixelSize: 10
   //                        display: AbstractButton.TextBesideIcon
                           onClicked: {
                               stationdev.qmlHostSendAuto(2011);
                           }
                       }


                   }

                   Rectangle {
                       id:row08c_c02;
                       width: parent.width*0.2;
                       height:parent.height*0.8
                       anchors.left: row08c_c01.right;

                       Button {
                           id: button1013
                           width: parent.width*0.8
                           height: parent.height*0.7
                           anchors.centerIn: parent
                           text: "现场机时间校准"
                           font.family: "Microsoft YaHei"
                           font.pixelSize: 10
                           onClicked: {
                               stationdev.qmlHostSendAuto(1013);
                           }
                       }
                   }

                   Rectangle {
                       id:row08c_c03;
                       width: parent.width*0.2;
                       height:parent.height*0.8
                       anchors.left: row08c_c02.right;
                       Button {
                           id: button2051
                           width: parent.width*0.8
                           height: parent.height*0.7
                           anchors.centerIn: parent
                           text: "上传分钟数据"
                           font.family: "Microsoft YaHei"
                           font.pixelSize: 10
                           onClicked: {
                               stationdev.qmlHostSendAuto(2051);
                           }
                       }

                   }
                   Rectangle {
                       id:row08c_c04;
                       width: parent.width*0.2;
                       height:parent.height*0.8
                       anchors.left: row08c_c03.right;
                       Button {
                           id: button2061
                           width: parent.width*0.8;
                           height:parent.height*0.7
                           anchors.centerIn: parent
                           text: "上传小时数据"
                           font.family: "Microsoft YaHei"
                           font.pixelSize: 10
                           onClicked: {
                               stationdev.qmlHostSendAuto(2061);
                           }
                       }


                   }
                   Rectangle {
                       id:row08c_c05;
                       width: parent.width*0.2;
                       height:parent.height*0.8
                       anchors.left: row08c_c04.right;
                       Button {
                           id: button2031
                           width: parent.width*0.8;
                           height:parent.height*0.7
                           anchors.centerIn: parent
                           text: "上传日历史数据"
                           font.family: "Microsoft YaHei"
                           font.pixelSize: 10
                           onClicked: {
                               stationdev.qmlHostSendAuto(2031);
                           }
                       }

                   }


               }

            //按钮区2
           Rectangle {
                   width: parent.width
                   id:row09c;
                   height:80;
                   //color:"blue";
                   anchors.top: row08c.bottom;

                   Rectangle {
                       id:row09c_c01;
                       width: parent.width*0.2;
                       height:parent.height*0.8
                       anchors.left: parent.left;
                       Button {
                           id: button2041
                           width: parent.width*0.8
                           height: parent.height*0.7
                           anchors.centerIn: parent
                           text: "设备日历史数据"
                           font.family: "Microsoft YaHei"
                           font.pixelSize: 10
                           display: AbstractButton.TextBesideIcon
                           spacing: 5
                           onClicked: {
                               stationdev.qmlHostSendAuto(2041);
                           }
                         }
                       }

                  Rectangle {
                      id:row09c_c02;
                      width: parent.width*0.2;
                      height:parent.height*0.8
                      anchors.left: row09c_c01.right;

                      Button {
                          id: button2081
                          width: parent.width*0.8
                          height: parent.height*0.7
                          anchors.centerIn: parent
                          text: "数采仪开机时间"
                          font.family: "Microsoft YaHei"
                          font.pixelSize: 10
                          onClicked: {
                              stationdev.qmlHostSendAuto(2081);
                          }
                      }
                  }

                  Rectangle {
                      id:row09c_c03;
                      width: parent.width*0.2;
                      height:parent.height*0.8
                      anchors.left: row09c_c02.right;
                      Button {
                          id: button3019
                          width: parent.width*0.8
                          height: parent.height*0.7
                          anchors.centerIn: parent
                          text: "设备唯一标识"
                          font.family: "Microsoft YaHei"
                          font.pixelSize: 10
                          onClicked: {
                              stationdev.qmlHostSendAuto(3019);
                          }
                      }

                  }

                  Rectangle {
                      id:row09c_c04;
                      width: parent.width*0.2;
                      height:parent.height*0.8
                      anchors.left: row09c_c03.right;
                      Button {
                          id: button3020
                          width: parent.width*0.8;
                          height:parent.height*0.7
                          anchors.centerIn: parent
                          text: "现场机信息"
                          font.family: "Microsoft YaHei"
                          font.pixelSize: 10
                          onClicked: {
                              stationdev.qmlHostSendAuto(3020);
                          }
                      }


                  }

                  Rectangle {
                              id:row09c_c05;
                              width: parent.width*0.2;
                              height:parent.height*0.8
                              anchors.left: row09c_c04.right;
                              Button {
                                  id: buttonNextpage
                                  width: parent.width*0.8;
                                  height:parent.height*0.7
                                  anchors.centerIn: parent
                                  text: "null"
                                  font.family: "Microsoft YaHei"
                                  font.pixelSize: 10
                                  onClicked: {

                                  }
                              }

                          }


                   }

           //分割线
           Rectangle {
                       width: parent.width
                       id:row10c;
                       height:20;
                       color:"red";
                       anchors.top: row09c.bottom;

                       Rectangle {
                           width: parent.width
                           id:row10c_c01;
                           height:5;
                           color:"blue";
                           anchors.centerIn: parent;

                           }
                       }
               }



        //设备因子设置对话框
        Dialog {
            id: deviceDialog
            width:swipeView.width*0.8;
            height:swipeView.height*0.65;
            x: (page.width - width) / 2
            y: 0;//(page.height - height) / 3
            //parent: Overlay.overlay

            focus: true
            modal: true
            title: "监测设备/因子设置<"+((qmldevice[0].deviceId==0)?"新建":qmldevice[0].deviceId.toString())+">"
            //standardButtons: Dialog.Ok | Dialog.Cancel
            font.pixelSize: 20
//            onAccepted:  console.log("(OK)")

            //设备名称
            Rectangle {
                    id:ddialog_R01;
                    width: parent.width;
                    height:50;
                    //color:"blue";
                    Rectangle {
                            id:ddialog_R01_C01;
                            width: parent.width/8;
                            height:parent.height;
                            anchors.left:  parent.left;
                            //color:"yellow";
                            Text {
                                 color: "#0c00d5"
                                 text: qsTr("设备名称:")
                                 anchors.margins: 10
                                 anchors.right: parent.right
                                 anchors.verticalCenter: parent.verticalCenter
                                 font.family: "Microsoft YaHei"
                                 font.pixelSize: 12;
                            }
                    }
                    Rectangle {
                            id:ddialog_R01_C02;
                            width: parent.width/4;
                            height:parent.height;
                            anchors.left:  ddialog_R01_C01.right;
                           // color:"red";
                            Text {
                                id: devicename
                                anchors.verticalCenter: parent.verticalCenter
                                text:qmldevice[0].deviceName;//station.text
                                font.pixelSize: 12
                                font.family: "Microsoft YaHei"//qsTr("")
                            }
                    }
            }

            //通讯端口
            Rectangle {
                    id:ddialog_R02;
                    anchors.top: ddialog_R01.bottom;
                    width: parent.width;
                    height:50;
                    //color:"blue";
                    Rectangle {
                            id:ddialog_R02_C01;
                            width: parent.width/8;
                            anchors.left:  parent.left;
                            height:50;
                            //color:"yellow";
                            Text {
                                 color: "#0c00d5"
                                 text: qsTr("采集端口:")
                                 anchors.margins: 10
                                 anchors.right: parent.right
                                 anchors.verticalCenter: parent.verticalCenter
                                 font.family: "Microsoft YaHei"
                                 font.pixelSize: 12;
                            }
                    }
                    Rectangle {
                            id:ddialog_R02_C02;
                            width: parent.width/4;
                            anchors.left:  ddialog_R02_C01.right;
                            height:50;
                            //color:"red";
                            ComboBox {
                                 id:selectPort
                                 width: parent.width*0.9
                                 height: parent.height*0.9
                                 anchors.left:parent.left;
                                 anchors.verticalCenter: parent.verticalCenter
                                 font.pixelSize: 10
                                 font.family: "Microsoft YaHei"
                                 focusPolicy: Qt.ClickFocus;
                                 model: portlist.text;
                                 currentIndex: portlist.indexOf(qmldevice[0].devicePort);
                                 //anchors.horizontalCenter: parent.horizontalCenter
                                onPressedChanged: {
                                    //if(!pressed) serialporthelper.querySerialInfo();
                                    if(!pressed)  qmlconncpp.serialRefresh();
                                }
                            }
                    }
            }
            //通讯协议
            Rectangle {
                    id:ddialog_R03;
                    anchors.top: ddialog_R02.bottom;
                    width: parent.width;
                    height:50;
                    //color:"blue";
                    Rectangle {
                            id:ddialog_R03_C01;
                            width: parent.width/8;
                            anchors.left:  parent.left;
                            height:50;
                            //color:"yellow";
                            Text {
                                 color: "#0c00d5"
                                 text: qsTr("设备协议:")
                                 anchors.margins: 10
                                 anchors.right: parent.right
                                 anchors.verticalCenter: parent.verticalCenter
                                 font.family: "Microsoft YaHei"
                                 font.pixelSize: 12;
                            }
                    }
                    Rectangle {
                            id:ddialog_R03_C02;
                            width: parent.width/4;
                            anchors.left:  ddialog_R03_C01.right;
                            height:50;
                            //color:"red";

                            ComboBox {
                                 id:selectProtocolGroup
                                 width: parent.width*0.9
                                 height: parent.height*0.9
                                 anchors.left:parent.left;
                                 anchors.verticalCenter: parent.verticalCenter
                                 font.pixelSize: 10
                                 font.family: "Microsoft YaHei"
                                 //focusPolicy: Qt.ClickFocus;
                                 model: qmldeviceProtocolGroup;
                                 currentIndex:qmldeviceProtocolGroup.indexOf(qmldevice[0].protocolLib);
                                 //anchors.horizontalCenter: parent.horizontalCenter
//                                onPressedChanged: {
//                                    //if(!pressed) serialporthelper.querySerialInfo();
//                                    //if(!pressed)  qmlconncpp.serialRefresh();
//                                    if(!pressed)
//                                    {
//                                        qmldeviceProtocolName=JSON.parse(qmlconncpp.getqmlDeviceProtocolByGroup(selectProtocolGroup.currentText))
//                                        //qmldeviceProtocolName.model=qmldeviceProtocolName;
//                                        //selectProtocolName.model=qmlconncpp.getqmlDeviceProtocolByGroup(selectProtocolGroup.currentText)
//                                        //console.log(selectProtocolGroup.currentText);
//                                        //console.log(qmldeviceProtocolName);

//                                    }
//                                }
                                onCurrentTextChanged:  {
                                     qmldeviceProtocolName=JSON.parse(qmlconncpp.getqmlDeviceProtocolByGroup(selectProtocolGroup.currentText));
                                    for(var i=0;i<selectProtocolName.count;i++)
                                    {
                                        if(selectProtocolName.model[i].protocolId===qmldevice[0].protocolId){selectProtocolName.currentIndex=i;break;}
                                    }

                                }


                            }
                    }

                    Rectangle {
                            id:ddialog_R03_C03;
                            width: parent.width/4;
                            anchors.left:  ddialog_R03_C02.right;
                            height:50;
                            //color:"red";

                            ComboBox {
                                 id:selectProtocolName
                                 textRole: "protocolText"
                                 width: parent.width*0.9
                                 height: parent.height*0.9
                                 anchors.left:parent.left;
                                 anchors.verticalCenter: parent.verticalCenter
                                 font.pixelSize: 10
                                 font.family: "Microsoft YaHei"
                                 //focusPolicy: Qt.ClickFocus;
                                 model: qmldeviceProtocolName;
                                 currentIndex:0;
                                 //anchors.horizontalCenter: parent.horizontalCenter
                                onPressedChanged: {
                                    //if(!pressed) serialporthelper.querySerialInfo();
                                    //if(!pressed)
                                    //if(!pressed)  console.log(qmlconncpp.getqmlDeviceProtocolGroup());
                                }
                            }
                    }




            }
            //协议地址
            Rectangle {
                    id:ddialog_R04;
                    anchors.top: ddialog_R03.bottom;
                    width: parent.width;
                    height:50;
                    //color:"blue";
                    Rectangle {
                            id:ddialog_R04_C01;
                            width: parent.width/8;
                            anchors.left:  parent.left;
                            height:50;
                            //color:"yellow";
                            Text {
                                 color: "#0c00d5"
                                 text: qsTr("协议地址:")
                                 anchors.margins: 10
                                 anchors.right: parent.right
                                 anchors.verticalCenter: parent.verticalCenter
                                 font.family: "Microsoft YaHei"
                                 font.pixelSize: 12;
                            }
                    }
                    Rectangle {
                            id:ddialog_R04_C02;
                            width: parent.width/4;
                            anchors.left:  ddialog_R04_C01.right;
                            height:50;
                            //color:"red";
                            SpinBox {
                                id: selectaddr
                                from:1;
                                to:255;
                                value: qmldevice[0].deviceAddr;
                                anchors.verticalCenter: parent.verticalCenter
                                font.pixelSize: 12;
                                editable: false
                            }
                    }
            }

            //提示信息
            Rectangle {
                    id:ddialog_usrMsg;
                    anchors.bottom: ddialog_Rlast.top;
                    width: parent.width;
                    height:50;
                    //color:"blue";
                    Text {
                        id:ddialogUsrMsgText
                         color: "red"
                         text: "";
                         anchors.margins: 10
                         anchors.left: parent.left
                         anchors.verticalCenter: parent.verticalCenter
                         font.family: "Microsoft YaHei"
                         font.pixelSize: 12;
                    }

            }
            //按钮
            Rectangle {
                    id:ddialog_Rlast;
                    anchors.bottom: parent.bottom;
                    width: parent.width;
                    height:50;
                    //color:"blue";
                    Rectangle {
                            id:ddialog_Rlast_C01;
                            width: parent.width/2;
                            anchors.left:  parent.left;
                            height:50;
                            //color:"yellow";
                            Button {
                                id: ddialog_btnUpdate
                                width: parent.width*0.8
                                height: parent.height*0.8
                                anchors.centerIn: parent
                                text: "提交更改"
                                font.family: "Microsoft YaHei"
                                font.pixelSize: 15
                                onClicked: {
                                    //stationdev.qmlHostSendAuto(3019);
                                    //ddialogUsrMsgText.text="对不起,该功能未完成!";
                                    //console.log(selectProtocolName.model[selectProtocolName.currentIndex].protocolId);
                                    //console.log(qmlconncpp.getqmlDeviceProtocolById(selectProtocolName.model[selectProtocolName.currentIndex].protocolId));

                                    var Ddata = {};
                                    if(qmldevice[0].deviceId>0) Ddata.id=qmldevice[0].deviceId;
                                    Ddata.deviceName=devicename.text;
                                    Ddata.devicePort=selectPort.currentText;
                                    Ddata.deviceAddr=selectaddr.value;
                                    Ddata.protocolIdHex=selectProtocolName.model[selectProtocolName.currentIndex].protocolId;
                                    //console.log(JSON.stringify(Ddata));
                                    if(qmlconncpp.setsqlDevice(JSON.stringify(Ddata))) {ddialogUsrMsgText.text=""; deviceDialog.close()} else ddialogUsrMsgText.text="操作失败!";
                                }
                            }
                    }
                    Rectangle {
                            id:ddialog_last_C02;
                            width: parent.width/2;
                            anchors.left:  ddialog_Rlast_C01.right;
                            height:50;
                            //color:"red";
                            Button {
                                id: ddialog_btnCancel
                                width: parent.width*0.8
                                height: parent.height*0.8
                                anchors.centerIn: parent
                                text: "取消更改"
                                font.family: "Microsoft YaHei"
                                font.pixelSize: 15
                                onClicked: {
                                    ddialogUsrMsgText.text="";
                                    deviceDialog.close()
                                }
                            }
                    }
            }

        }


        //上报平台设置对话框
        Dialog {
            id: hostDialog
            width:swipeView.width*0.8;
            height:swipeView.height*0.65;
            x: (page.width - width) / 2
            y: 0;//(page.height - height) / 3
            //parent: Overlay.overlay

            focus: true
            modal: true
            title: "上报平台设置"
            standardButtons: Dialog.Ok | Dialog.Cancel
            //                Rectangle {
            //                     id: row03_C01
            //                     width: parent.width*0.08
            //                     height: parent.height*0.9
            //                     anchors.left:row03.left;
            //                     anchors.verticalCenter: parent.verticalCenter

            //                     Text {
            ////                         width: parent.width*0.8
            ////                         height: parent.height*0.8
            //                          color: "#0c00d5"
            //                          text: qsTr("平台名称:")
            //                          anchors.right: parent.right
            //                          anchors.verticalCenter: parent.verticalCenter
            //                          font.family: "Microsoft YaHei"
            //                          font.pixelSize: 8+(parent.width/10);
            //                     }
            //                }



            //                    Rectangle {
            //                        id: row03_C02
            //                        width: parent.width*0.15
            //                        height: row03_C01.height
            //                        anchors.left:row03_C01.right;
            //                        anchors.verticalCenter: parent.verticalCenter
            //                         TextField {
            //                             id: ptname

            //                             width: parent.width*0.9;
            //                             height: parent.height*0.9;
            //                             anchors.verticalCenter: parent.verticalCenter
            //                             text: station.text
            //                             font.pixelSize: 10
            //                             renderType: Text.QtRendering
            //                             scale: 1
            //                             font.family: "Microsoft YaHei"
            //                             wrapMode: Text.NoWrap
            //                             placeholderText: "给平台取个名字"
            //                             z: 0
            //                             opacity: 1
            //                         }
            //                    }

            //                    Rectangle {
            //                        id: row03_C03
            //                        width: row03_C01.width
            //                        height: row03_C01.height
            //                        anchors.left:row03_C02.right;
            //                        anchors.verticalCenter: parent.verticalCenter
            //                        Text {
            //   //                         width: parent.width*0.8
            //   //                         height: parent.height*0.8
            //                             color: "#0c00d5"
            //                             text: qsTr("平台地址:")
            //                             anchors.right: parent.right
            //                             anchors.verticalCenter: parent.verticalCenter
            //                             font.family: "Microsoft YaHei"
            //                          font.pixelSize: 8+(parent.width/10);
            //                        }
            //                    }


            //                    Rectangle {
            //                        id: row03_C04
            //                        width: row03_C02.width
            //                        height: row03_C01.height
            //                        anchors.left:row03_C03.right;
            //                        anchors.verticalCenter: parent.verticalCenter
            //                         TextField {
            //                             id: inputIp
            //                             width: parent.width*0.9;
            //                             height: parent.height*0.9;
            //                             anchors.verticalCenter: parent.verticalCenter
            //                             text: "192.168.43.35"
            //                             font.pixelSize: 10
            //                             scale: 1
            //                             z: 0
            //                             placeholderText: "上报平台的IP地址"
            //                             inputMethodHints: Qt.ImhDigitsOnly
            //                             wrapMode: Text.NoWrap
            //                             font.family: "Microsoft YaHei"
            //                             renderType: Text.QtRendering
            //                             opacity: 1
            //                         }
            //                    }

            //                    Rectangle {
            //                        id: row03_C05
            //                        width: row03_C01.width
            //                        height: row03_C01.height
            //                        anchors.left:row03_C04.right;
            //                        anchors.verticalCenter: parent.verticalCenter
            //                        Text {
            //   //                         width: parent.width*0.8
            //   //                         height: parent.height*0.8
            //                             color: "#0c00d5"
            //                             text: qsTr("平台端口:")
            //                             anchors.right: parent.right
            //                             anchors.verticalCenter: parent.verticalCenter
            //                             font.family: "Microsoft YaHei"
            //                          font.pixelSize: 8+(parent.width/10);
            //                        }
            //                    }

            //                    Rectangle {
            //                        id: row03_C06
            //                        width: row03_C02.width*0.6
            //                        height: row03_C01.height
            //                        anchors.left:row03_C05.right;
            //                        anchors.verticalCenter: parent.verticalCenter
            //                         TextField {
            //                             id: inputPort
            //                             width: parent.width*0.9;
            //                             height: parent.height*0.9;
            //                             anchors.verticalCenter: parent.verticalCenter
            //                             text: "8234"
            //                             font.pixelSize: 10
            //                             scale: 1
            //                             z: 0
            //                             placeholderText: "平台端口"
            //                             inputMethodHints: Qt.ImhDigitsOnly
            //                             wrapMode: Text.NoWrap
            //                             font.family: "Microsoft YaHei"
            //                             renderType: Text.QtRendering
            //                             opacity: 1
            //                         }
            //                    }


            //                    Rectangle {
            //                        id: row03_C07
            //                        width: row03_C01.width
            //                        height: row03_C01.height
            //                        anchors.left:row03_C06.right;
            //                        anchors.verticalCenter: parent.verticalCenter
            //                        Text {
            //   //                         width: parent.width*0.8
            //   //                         height: parent.height*0.8
            //                             color: "#0c00d5"
            //                             text: qsTr("数据协议:")
            //                             anchors.right: parent.right
            //                             anchors.verticalCenter: parent.verticalCenter
            //                             font.family: "Microsoft YaHei"
            //                          font.pixelSize: 8+(parent.width/10);
            //                        }
            //                    }


            //                    Rectangle {
            //                        id: row03_C08
            //                        width: row03_C02.width*1.4
            //                        height: row03_C01.height
            //                        anchors.left:row03_C07.right;
            //                        anchors.verticalCenter: parent.verticalCenter
            //                         ComboBox {
            //                             id: selectnetxy
            //                             width: parent.width*0.9
            //                             height: parent.height*0.9
            //                             anchors.left:parent.left;
            //                             anchors.verticalCenter: parent.verticalCenter
            //                             font.pixelSize: 10
            //                             focusPolicy: Qt.ClickFocus
            //                             model: ["HJ212-2017"]//,"HJ212-2015"]
            //                             font.family: "Microsoft YaHei"
            //                         }
            //                    }

            //                    Rectangle {
            //                        id: row03_C09
            //                        width: row03_C01.width
            //                        height: row03_C01.height
            //                        anchors.left:row03_C08.right;
            //                        anchors.verticalCenter: parent.verticalCenter
            //                         Button {
            //                             id: buttonhost
            //                             width: parent.width*0.9
            //                             height: parent.height*0.9
            //                             anchors.left:parent.left;
            //                             anchors.verticalCenter: parent.verticalCenter
            //                             text: "添加"
            //                             font.pixelSize: 10
            //                             display: AbstractButton.TextBesideIcon
            //                             spacing: 5
            //                             font.family: "Microsoft YaHei"
            //                             onClicked: {
            //                                 hostlist.addHost(ptname.text,inputIp.text,inputPort.text,selectnetxy.currentText);
            //                                 console.log(hostlist.rowCount());
            //                             }
            //                         }

            //                    }

        }
    }

    footer: TabBar {
        id: tabBar
        z: 98
        currentIndex: swipeView.currentIndex

        TabButton {
            text: "通讯展示"
        }
        TabButton {
            text: "数据展示"
        }
        TabButton {
            text: "站点信息"
        }
    }
}
